package com.coolcard.risk.service;

import com.coolcard.risk.entity.RiskInfo;
import com.coolcard.risk.repository.RiskInfoRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class RiskInfoService {
    private final RiskInfoRepository riskInfoRepository;

    public RiskInfo getRiskInfo(Long id) {
        return riskInfoRepository.findById(id).get();
    }

    public RiskInfo saveRiskInfo(RiskInfo riskInfo) {
        return riskInfoRepository.save(riskInfo);
    }

    public void deleteRiskInfo(Long id) {
        riskInfoRepository.deleteById(id);
    }

    public RiskInfo updateRiskInfo(RiskInfo riskInfo) {
        return riskInfoRepository.save(riskInfo);
    }

    public List<RiskInfo> getAllRiskInfo() {
        return riskInfoRepository.findAll();
    }
}
